byte myByte;  //Input character
int buttonState;  //Door state
char charmyByte;  //convert input into char. 

void setup(){
    pinMode(9, OUTPUT);  //DOOR LOCK MECHANISM
    pinMode(10, OUTPUT);  //FRONT LAMP OF THE CAR
    pinMode(11, INPUT);  //DOOR CLOSE INDICATOR
    Serial.begin(9600);
}
//

void loop() {
        buttonState = digitalRead(11);
        //Serial.print(buttonState);
        
        switch ( buttonState ) {
        case HIGH: // The car is locked
          myByte = Serial.read();
          charmyByte = char(myByte);
          
          if(charmyByte == 'L'){
            Serial.write("Lock!!!\n");
            digitalWrite(9, HIGH);  //DOOR LOCK MECH. IS WORKING
            delay(100);
            digitalWrite(10, HIGH);  // FRONT LAMPS ARE BLINKING FOR 1 SEC
            delay(1000);
            digitalWrite(10, LOW);
          }
          
          else if (charmyByte == 'U'){
            Serial.write("Unlock!!!\n");
            digitalWrite(9, LOW);  //DOOR LOCK MECH. IS RRELEASED
            delay(100);
            digitalWrite(10, HIGH); // FRONT LAMPS ARE BLINKING FOR 1 SEC, TWICE
            delay(1000);
            digitalWrite(10, LOW);
            delay(1000);
            digitalWrite(10, HIGH);
            delay(1000);
            digitalWrite(10, LOW);
          }
          break;
          
       case LOW:  //IF DOOR AREN'T CLOSED
          Serial.print("Doors aren't closed!!!\n");
          delay(1000);
          digitalWrite(9, LOW);
          digitalWrite(10, LOW);
       break;
      }
    
    
}
      
       
    
